home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Floppyshop 2
/
Floppyshop - 2.zip
/
Floppyshop - 2.iso
/
art&graf.ix
/
art-3485
/
art-5570
/
atsirdss.lst
< prev
next >
Wrap
File List
|
1994-08-10
|
4KB
|
166 lines
' **** Atari SIRDS program v2.0 ****
' routine from the SIRDS FAQ
' 640x400 monochrome display version
' single depth from a degas picture
'
' read *.pi3 (Degas mono screen) file into thedepth array
' write *.pic mono screen file
'
bkdepth%=-800 ! depth of background in pixels
e%=180 ! eye separation in pixels
o%=700 ! observer-screen distance in pixels
oversam%=1 ! oversampling ratio -- can be 1, 2, 4, 6
dohiddenrem!=FALSE ! enable/disable SLOW hidden point removal
xres%=640 ! width of the picture in pixels
yres%=390 ! height of picture in pixels
numcolors%=2
'
DIM thedepth|(xres%*yres%)
depthofs%=VARPTR(thedepth|(0))
DIM link%(xres%*oversam%)
DIM pixels%(xres%*oversam%)
DIM z%(xres%)
'
FILESELECT "\*.pi3","",dep$
IF dep$=""
END
ENDIF
OPEN "i",#1,dep$
SEEK #1,34
BGET #1,XBIOS(2),32000
CLOSE #1
'
init_depth
CLS
init_sirds
do_sirds
PRINT CHR$(7);
'
FILESELECT "\*.pic","",sir$
IF sir$=""
END
ENDIF
BSAVE sir$,XBIOS(2),32000
END
'
'
'
PROCEDURE init_depth
LOCAL x%,y%
FOR y%=0 TO yres%-1
FOR x%=0 TO xres%-1
IF POINT(x%,y%)
thedepth|(y%*xres%+x%)=128 ! 0=far, 255=near
ENDIF
NEXT x%
NEXT y%
RETURN
'
PROCEDURE init_sirds
' add "help lines"
LOCAL x%,y%,helpdist,th%
helpdist=ABS(bkdepth%)*e%/(2*(ABS(bkdepth%)+o%))
th%=0
FOR y%=9 DOWNTO 0
FOR x%=xres%/2-helpdist-th% TO xres%/2-helpdist+th%
PLOT x%,y%
NEXT x%
FOR x%=xres%/2+helpdist-th% TO xres%/2+helpdist+th%
PLOT x%,y%
NEXT x%
INC th%
NEXT y%
RETURN
'
PROCEDURE do_sirds
' render the SIRDS
LOCAL x%,y%,h%,u%,dx%,c%,xx%,highest%,separation%,left%,right%,pp%,v,visible!
FOR y%=0 TO yres%-1
FOR x%=0 TO xres%*oversam%-1
link%(x%)=x%
NEXT x%
highest%=bkdepth%
FOR x%=0 TO xres%-1
' h%=bkdepth%+128+63*(SIN(x%/70*PI)+COS(y%/70*PI))
h%=bkdepth%+thedepth|(y%*xres%+x%)
z%(x%)=h%
IF h%>highest%
highest%=h%
ENDIF
NEXT x%
FOR x%=0 TO xres%*oversam%-1
separation%=(e%*oversam%*z%(x%/oversam%))/(z%(x%/oversam%)-o%)
left%=x%-separation%/2
right%=left%+separation%
IF (left%>=0) AND (right%<xres%*oversam%)
visible!=TRUE
IF dohiddenrem!
v=2*(o%-z%(x%/oversam%))/e%
dx%=1
REPEAT
u%=z%(x%/oversam%)+dx%*v
IF (z%((x%+dx%)/oversam%)>=u%) OR (z%((x%-dx%)/oversam%)>=u%)
visible!=FALSE
ENDIF
INC dx%
UNTIL (u%>highest%) OR (NOT visible!)
ENDIF
IF visible!
link%(right%)=left%
ENDIF
ENDIF
NEXT x%
pp%=0
FOR x%=0 TO xres%*oversam%-1
IF link%(x%)=x%
IF (pp% MOD oversam%)=0
c%=RANDOM(numcolors%)
ENDIF
pixels%(x%)=c%
INC pp%
ELSE
pixels%(x%)=pixels%(link%(x%))
ENDIF
NEXT x%
FOR x%=0 TO xres%-1
xx%=x%*oversam%
SELECT oversam%
CASE 1
c%=pixels%(xx%)
CASE 2
IF (x%>0) AND (x%<xres%-1)
c%=pixels%(xx%)*42+(pixels%(xx%-1)+pixels%(xx%+1))*24
c%=c%+(pixels%(xx%-2)+pixels%(xx%+2))*5
c%=c%/100
ELSE
c%=pixels%(xx%)
ENDIF
CASE 4
IF (x%>0) AND (x%<xres%-1)
c%=pixels%(xx%)*26+(pixels%(xx%-1)+pixels%(xx%+1))*18
c%=c%+(pixels%(xx%-2)+pixels%(xx%+2))*12
c%=c%+(pixels%(xx%-3)+pixels%(xx%+3))*7
c%=c%/100
ELSE
c%=pixels%(xx%)
ENDIF
CASE 6
IF (x%>0) AND (x%<xres%-1)
c%=pixels%(xx%)*14+(pixels%(xx%-1)+pixels%(xx%+1))*14
c%=c%+(pixels%(xx%-2)+pixels%(xx%+2))*11
c%=c%+(pixels%(xx%-3)+pixels%(xx%+3))*8
c%=c%+(pixels%(xx%-4)+pixels%(xx%+4))*5
c%=c%+(pixels%(xx%-5)+pixels%(xx%+5))*3
c%=c%+(pixels%(xx%-6)+pixels%(xx%+6))*2
c%=c%/100
ELSE
c%=pixels%(xx%)
ENDIF
ENDSELECT
IF c%=0
PLOT x%,y%+10
ENDIF
NEXT x%
NEXT y%
RETURN